package com.sso.managedBean;

import javax.faces.context.FacesContext;

import org.operamasks.faces.annotation.Accessible;
import org.operamasks.faces.annotation.BeforeRender;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.Inject;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.annotation.SaveState;

import com.base.commons.SpringBeanHolder;
import com.sso.entity.DicSystem;
import com.sso.service.IDicSystemService;
@ManagedBean(name = "sso_showSystemBean", scope = ManagedBeanScope.REQUEST)
public class ShowSystemBean {
	
	protected IDicSystemService dicSystemService = SpringBeanHolder
	.getBean("dicSystemService");
	
	@Bind
	@Accessible
	@SaveState
	protected String systemID;
	protected DicSystem system;
	
	// 系统名称
	@Bind(id = "systemName", attribute = "value")
	protected String systemName;
	// 描述
	@Bind(id = "systemRemark", attribute = "value")
	protected String systemRemark;
	//系统地址
	@Bind(id = "systemUrl", attribute = "value")
	protected String systemUrl;
	//系统服务地址
	@Bind(id = "systemServiceAddress", attribute = "value")
	protected String systemServiceAddress;
	
	@Inject
	private FacesContext context;
	
	@SaveState
	private String first;
	
	@BeforeRender
	public void beforeRender(boolean isPostBack) throws Exception {
		if (!isPostBack) {
			systemID = context.getExternalContext().getRequestParameterMap()
					.get("id");
			if (!"".equals(systemID) && null != systemID) {
				system = dicSystemService.getBySystemID(systemID);
				if (system != null) {
					systemID = system.getId();
					systemName=system.getSystemName();
					systemRemark=system.getSystemRemark();
					systemUrl = system.getSystemUrl();
					systemServiceAddress = system.getSystemServiceAddress();
				}
			}
		}
	}
}
